/*--------------------------------------------------------------
 * File: demo12.c 编码类型：C语言  UTF-8
 * Author WRS (1352509846@qq.com)
 * 功能: 交换两个数的值
 * 1.使用临时变量
 * 2.不使用临时变量
 * 3.
 * Version 0.1
 * Date 2021-11-23 
 * 
 * @copyright Copyright (c) 2021
 * 
----------------------------------------------------------------*/

#include "stdio.h"

//方法1  使用临时变量
static void Exchange_1(int *a, int *b)
{
    int c = 0;
    c = *a;
    *a = *b;
    *b = c;
}

//方法2  不使用临时变量
static void Exchange_2(int *a, int *b)
{
    *a = *a + *b;
    *b = *a - *b;
    *a = *a - *b;
}

int main(int argc, char const *argv[])
{
    int a = 12;
    int b = 66;
    printf("a = %d , b = %d \n",a,b);
    Exchange_2(&a, &b);
    printf("a = %d , b = %d \n",a,b);
    return 0;
}
